<!doctype html>
<html>
<head>
<meta name="Generator"  />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>收货地址</title>
<meta name="Keywords" content="Call管家" />
<meta name="Description" content="Call管家" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>

<link rel="stylesheet" href="__HOMECSS__/style.css">
<script src="__HOMEJS__/jquery-1.7.2.min.js"></script>

</head>

<body style="margin-bottom: 54px;">

<!-- 收货地址 -->
<ul>
    {volist name='address_list' id='vo'}
    <li class="address_list">
        <div class="addresslist_top">
            <p class="namephone"><span>收货人：{$vo.consignee}</span> <span>{$vo.mobile}</span></p>
            <p class="address">收货人：{$vo.province}{$vo.city}{$vo.district}{$vo.address}</p>
        </div>
        <div class="addresslist_bottom">
            <div class="{if condition='($vo[is_default] eq 1)'}morem1 morem{else/}morem{/if}" onclick="edit_status({$vo.id})">
                默认地址
            </div>
            <div class="icon">
                <span  onclick="edit({$vo.id})">编辑</span>
                <span  onclick="del({$vo.id})">删除</span>
            </div>
        </div>
    </li>
    {/volist}

</ul>

<div class="address_new">
    <p>添加新地址</p>
</div>
</body>
<script src="__PUBLIC__/layer/layer.js"></script>
<script>
    $(function () {
        $(".addresslist_bottom .morem").click(function () {
            $(".addresslist_bottom .morem").removeClass('morem1')
            $(this).addClass('morem1')
        })

        $(".address_new").click(function () {
            window.location.href = "{:Url('User/add_address',['is_cart'=>I('get.is_cart')])}"
        })
    })
    //删除地址
    function del(id){
        $.ajax({
                type:"post",
                url:"{:Url('User/del_address')}",
                dataType:'json',
                data:{"id":id},
                success:function(result){
                       if(result.status==1){
                            layer.msg(result.info,{icon:1,time:1500});
                            window.location.reload();
                        }else{
                            layer.msg(result.info,{icon:2,time:1500});
                        }
                }
        });
    }
    //编辑地址
    function edit(id){
         window.location.href = "{:Url('Home/User/edit_address/id/"+id+"')}";
    }
    //设置默认地址
    function edit_status(id){
        $.ajax({
                type:"post",
                url:"{:Url('User/ajax_address_status')}",
                dataType:'json',
                data:{"id":id},
                success:function(result){
                       if(result.status==1){
                            layer.msg(result.info,{icon:1,time:1500});
                            window.location.reload();
                        }else{
                            layer.msg(result.info,{icon:2,time:1500});
                        }
                }
        });
    }
</script>

</html>
